package com.ruoyi.web.controller.process;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.domain.WorkLoadplate;
import com.ruoyi.process.service.IWorkLoadplateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 装盘管理Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/process/loadplate")
public class WorkLoadplateController extends BaseController
{
    @Autowired
    private IWorkLoadplateService workLoadplateService;

    /**
     * 查询装盘管理列表
     */
    @PreAuthorize("@ss.hasPermi('process:loadplate:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkLoadplate workLoadplate)
    {
        startPage();
        List<WorkLoadplate> list = workLoadplateService.selectWorkLoadplateList(workLoadplate);
        return getDataTable(list);
    }

    /**
     * 导出装盘管理列表
     */
    @PreAuthorize("@ss.hasPermi('process:loadplate:export')")
    @Log(title = "装盘管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WorkLoadplate workLoadplate)
    {
        List<WorkLoadplate> list = workLoadplateService.selectWorkLoadplateList(workLoadplate);
        ExcelUtil<WorkLoadplate> util = new ExcelUtil<WorkLoadplate>(WorkLoadplate.class);
        return util.exportExcel(list, "装盘管理数据");
    }

    /**
     * 获取装盘管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('process:loadplate:query')")
    @GetMapping(value = "/{workLoadplateId}")
    public AjaxResult getInfo(@PathVariable("workLoadplateId") Long workLoadplateId)
    {
        return AjaxResult.success(workLoadplateService.selectWorkLoadplateById(workLoadplateId));
    }

    /**
     * 新增装盘管理
     */
    @PreAuthorize("@ss.hasPermi('process:loadplate:add')")
    @Log(title = "装盘管理", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type= InjectType.Insert)
    public AjaxResult add(@RequestBody WorkLoadplate workLoadplate)
    {
        return toAjax(workLoadplateService.insertWorkLoadplate(workLoadplate));
    }

    /**
     * 修改装盘管理
     */
    @PreAuthorize("@ss.hasPermi('process:loadplate:edit')")
    @Log(title = "装盘管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type= InjectType.Update)
    public AjaxResult edit(@RequestBody WorkLoadplate workLoadplate)
    {
        return toAjax(workLoadplateService.updateWorkLoadplate(workLoadplate));
    }

    /**
     * 删除装盘管理
     */
    @PreAuthorize("@ss.hasPermi('process:loadplate:remove')")
    @Log(title = "装盘管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{workLoadplateIds}")
    public AjaxResult remove(@PathVariable Long[] workLoadplateIds)
    {
        return toAjax(workLoadplateService.deleteWorkLoadplateByIds(workLoadplateIds));
    }
}
